<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    var predata = new Date("2020/6/24 18:00:00")
    setInterval(function(){
        var currdata = new Date()
        timeCha(predata,currdata,function(value){
           document.body.innerHTML = "距离回家倒计时还有"+value.day+"天"+value.hour+"时"+value.min+"分"+value.second+"秒";
        })
    },1000)
    
    function timeCha(data1,data2,callback){
    var t1 = data1.getTime()
    var t2 = data2.getTime()

    var day = parseInt(Math.abs(t2-t1)/1000/60/60/24);
    var hours =parseInt(( Math.abs(t2-t1)/1000/60/60 )% 24) 
    var min =parseInt(( Math.abs(t2-t1)/1000/60 )% 60) 
    var second =parseInt(( Math.abs(t2-t1)/1000)% 60)
    var obj = {day:day,hour:hours,min:min,second:second}
    return callback(obj)
}
</script>
</html>